package day_2022_7_to_8.day48;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author haomin
 * @date 2022/08/23 21:25
 **/
public class Day38_3_Num90_SubsetsWithDup {
    class Solution {
        List<List<Integer>> ans = new ArrayList<>();
        public List<List<Integer>> subsetsWithDup(int[] nums) {
            List<Integer> ret = new ArrayList<>();
            Arrays.sort(nums);
            dfs(nums, 0, ret);
            return ans;
        }
        private void dfs(int[] nums, int start, List<Integer> ret){
            if(!ans.contains(ret)) ans.add(new ArrayList<>(ret));
            for(int i = start; i < nums.length; i++){
                ret.add(nums[i]);
                dfs(nums, i + 1, ret);
                ret.remove(ret.size()-1);
            }
        }
    }
}